/**
 * 
 */
package com.gragra.processText;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import com.gragra.util.FileLineForEach;
/**
 * This class is used to remove the leading number and tab from the sentences of corpora in the format of the Leipozig corpora collection.
 * @author Christoph Teichmann
 * created Nov 13, 2012 2:56:25 PM
 * @version 0.1
 */
public class RemoveNumbering
{
	/**
	 * Needs to be called with two arguments, first is the name of the input file, second is the name of the output file, which will be overwritten or created.
	 * This method will replace all the patterns matching "^\\d+\t" at the beginning of a new line.
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String... args) throws IOException
	{
		final BufferedReader in = new BufferedReader(new FileReader(args[0]));
		final BufferedWriter out = new BufferedWriter(new FileWriter(args[1]));
		final boolean[] first = new boolean[] {true};
		new FileLineForEach(in)
		{
			public void apply(String s)
			{
				if(first[0])
				{first[0] = false;}
				else
				{
					try
					{out.newLine();}
					catch (IOException e)
					{}
				}
				try
				{
					out.write(s.replaceAll("^\\d+\t", "").trim());
				}
				catch (IOException e)
				{}
			}
		};
		in.close();
		out.close();
	}
}